package models;

import play.*;
import play.data.validation.Email;
import play.db.jpa.*;

import javax.persistence.*;
import java.util.*;

@Entity
public class OrderItem extends BaseEntity {
	
	//数量
	public Long quantity;
	//成本价
	public double cost;
	//出售价
	public double price;
	//每件的重量(KG)
	public double weightPerUnit;
	//备注
	public String remark;
	
	@ManyToOne
	public Order order;
	
	@OneToOne
	public Commodity commodity;
	
	public OrderItem clone() {
		OrderItem orderItem = new OrderItem();
		orderItem.commodity = commodity;
		orderItem.quantity = quantity;
		orderItem.cost = cost;
		orderItem.price = price;
		orderItem.weightPerUnit = weightPerUnit;
		orderItem.remark = remark;
		orderItem.order = order;
		orderItem.createAt = this.createAt;
		orderItem.createByAdmin = this.createByAdmin;
		orderItem.createByUser = this.createByUser;
		orderItem.creatorType = this.creatorType;
		orderItem.lastModifiedAt = this.lastModifiedAt;
		orderItem.lastModifiedByAdmin = this.lastModifiedByAdmin;
		orderItem.lastModifiedByUser = this.lastModifiedByUser;
		orderItem.modifierType = this.modifierType;
		orderItem.status = this.status;
		return orderItem;
	}
}
